package thefirst.LessonSerch.model;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import thefirst.common.PagingBean;

@Service
public class LessonBoardServiceImpl implements LessonBoardService {
	@Resource(name = "lessonBoardDaoImpl")
	private LessonBoardDao lessonBoardDao;

	@Override
	public void writeLessonBoard(LessonBoardVO lbvo) throws SQLException {
		lessonBoardDao.writeLessonBoard(lbvo);
	}

	@Override
	public LessonBoardListVO getLessonBoardList(String pageNo)
			throws SQLException {

		if (pageNo == null || pageNo == "") {
			pageNo = "1";
		}
		List<LessonBoardVO> list = lessonBoardDao.getLessonBoardList(pageNo);
		int total=lessonBoardDao.totalLessonContent();
		PagingBean paging = new PagingBean(total, Integer.parseInt(pageNo));
		LessonBoardListVO lbList = new LessonBoardListVO(list, paging);
		return lbList;
	}

	@Override
	public LessonBoardVO showLessonBoardInfoNoHits(int no) throws SQLException {
		LessonBoardVO lbvo=lessonBoardDao.showLessonBoardInfoNoHits(no);
		return lbvo;
	}

}
